package br.unb.validator;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class FormatoData {
	String data_br;   
    java.util.Date data; 
    DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
  
    public String getDataBR(String data_br) {   
    	if(data_br == null){
    		return "__/__/____";
    	}
    	
        try {   
            data = df2.parse(data_br);   
        } catch (Exception e) {
            data = null;   
        }   
  
        return df.format(data);   
    }   
  
    public String getData(String data_br) {   
    	if(data_br.equals("__/__/____")){
    		return "0000-00-00";
    	}
        try {   
           data = df.parse(data_br.trim());   
        } catch (ParseException ex) {
           data = null;   
        }   
  
        return df2.format(data);   
    }

}
